package com.common;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

import java.util.List;
import java.util.Map;

/**
 * Created by xiang on 2017/7/4.
 *
 */
public class RegisterTool extends JdbcDaoSupport {

    public String getEmailNum(String sql, String userName){
        return getJdbcTemplate().queryForObject(sql, new Object[]{userName}, String.class);
    }

    public int changePassword(String sql, String newPassword, String email){
        return getJdbcTemplate().update(sql, newPassword, email);
    }

    public boolean checkUser(String sql, String userName){
        List<Map<String, Object>> list = getJdbcTemplate().queryForList(sql, userName);
        return list.size() > 0;
    }

    public boolean checkLogin(String sql,String content) {
        List<Map<String, Object>> list = getJdbcTemplate().queryForList(sql, content);
        return list.size() > 0;
    }
}
